Navicat provides SQL Builder for building queries visually. It allows you to create and edit queries without knowledge of SQL. The database objects are displayed in left pane. Whereas in the right pane, it is divided into two portions: the upper Diagram Design pane, and the lower Criteria Selection pane.
In Query Designer, click the
button to open the visual SQL Builder.
Note: SQL Builder supports SELECT statement only. Use SQL Editor for creating complex queries.
Drag a table/view from the left pane to the Diagram Design pane or double-click it to add it to query. To include a field in the query, check the left of the field name in the Diagram Design pane. To include all the fields, click the * checkbox.
To remove the object from the Diagram Design pane, click the cross button at the object caption.
To add the table/view alias, simply double-click the table/view name and enter the alias in the Diagram Design pane.
To associate database objects by two fields, just drag one field from the object to another and a line will appear between the linked fields.
Hint: To delete a link of an object, control-click the link and select Delete.
To change the association between the links, control-click the link and choose the properties item from the pop-up menu. You can change the Preserve.
Only Intersection
Select all rows from both objects as long as there is a match between the linked fields in both objects.
All from object_1 and only matches from object_2
Select all rows from object_1, with the matching rows in object_2.
The fields you have selected in the Diagram Design pane will be displayed in the SELECT pane which allows you to edit the output fields of the query.
Actual Field Name
Assumed you opened a table in the Diagram Design pane, you can click the checkbox of a field in order to add the field to Select pane.
Field Alias
Field Alias will be displayed in the grid of your query result. You can enter a field alias here.
You can drag and drop a field from field box to the WHERE pane. To define your own criteria, type the SQL condition statement in the pane. It will be embedded in the WHERE part of your query statement.
You can drag and drop a field from field box to the GROUP BY pane. To define your own criteria, type the SQL condition statement in the pane. The conditions will be included into the GROUP BY statement of the current query.
You can drag and drop a field from field box to the HAVING pane. To define your own criteria, type the SQL condition statement in the pane. The conditions will be included into the HAVING statement of the current query.
You can set the conditions of sorting the query records. To set the sorting order of a field, you can change the Sort Order in the ORDER BY pane.